package com.hzwq.mds.exception;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.ui.Model;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;
@RestControllerAdvice
public class UnionExceptionHandler {

    /**
     * Description : 全局异常捕捉处理
     * @param ex
     * @return
     */
    @ExceptionHandler(MyException.class)
    public Map errorHandler(MyException ex) {
        Map map = new HashMap();
        map.put("code", ex.getCode());
        map.put("msg", ex.getMessage());
        map.put("success", false);
        return map;
    }
}
